<!--
 * @Description: 
 * @Author: liehaozhong
 * @LastEditor: liehaozhong
 * @Date: 2020-07-11 16:20:24
 * @LastEditTime: 2020-08-05 18:48:32
-->
<template>
  <div>
    <span>{{item.title}}</span>
    &nbsp;
    <span>(数量 {{item.quantity}})</span>
    &nbsp;
    <a href="#" @click="addToCart(item)">增加</a>
    &nbsp;
    <a href="#" @click="delFromCart(item)">减少</a>
  </div>
</template>

<script>
import { mapMutations } from 'vuex'

export default {
  props: {
    item: {
      type: Object,
      default() {
        return {
          // id: 1,
          // title: '商品A',
          // price: 10,
          // quantity: 1 // 购物数量
        };
      }
    }
  },
  methods: {
    ...mapMutations('cart', [
      'addToCart',
      'delFromCart'
    ])
  }
};
</script>